package com.xy.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.EmbeddedValueResolverAware;
import org.springframework.stereotype.Component;
import org.springframework.util.StringValueResolver;

/**
 * @author 谢阳
 * @version 1.8.0_131
 * @date 2022/4/8 16:12
 * @description
 */

@Component
public class Red implements ApplicationContextAware, BeanNameAware, EmbeddedValueResolverAware {
    private ApplicationContext context;
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("red applicationContext = " + applicationContext);
        this.context = applicationContext;
    }

    @Override
    public void setBeanName(String name) {
        System.out.println("red name = " + name);
    }

    @Override
    public void setEmbeddedValueResolver(StringValueResolver resolver) {
        System.out.println("resolver = " + resolver);
        System.out.println(resolver.resolveStringValue("你好 ${os.name} ,我是#{10*36}"));
    }
}
